package com.barbarosso.video.view {
	import com.barbarosso.video.model.AssetProxy;	
	
	import nl.demonsters.debugger.MonsterDebugger;	
	
	import com.barbarosso.video.model.VideoProxy;	
	import com.barbarosso.video.constants.VideoConst;	
	import com.barbarosso.video.view.components.VideoController;
	
	import org.puremvc.as3.multicore.interfaces.IMediator;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.patterns.mediator.Mediator;	

	/**
	 * @author barbarosso
	 */
	public class VideoControllerMediator extends Mediator implements IMediator {
		
		public static const NAME : String = "com.barbarosso.video.view.VideoControllerMediator";
		
		public function VideoControllerMediator(mediatorName : String , viewComponent : VideoController) {
			super(mediatorName, viewComponent);
		}
		
		
		override public function listNotificationInterests() : Array {
			return [VideoConst.STREAM_PROGRESS];
		}
		
		override public function handleNotification(notification : INotification) : void {
			switch (notification.getName()) {
				case VideoConst.STREAM_PROGRESS:
				{
					MonsterDebugger.trace(this, videoProxy.nsProgress);
					break;
				}
				case VideoConst.ASSETS_LOADED:
					{
					view.addChild(assetProxy.videoSkin);
					break;
				}
				default:
				{
					break;
				}
			}
		}
		
		override public function onRegister() : void {
			
		}
		
		protected function get view() : VideoController{
			return viewComponent as VideoController;
		}
		
		protected function get videoProxy() : VideoProxy {
			return facade.retrieveProxy(VideoProxy .NAME) as VideoProxy ;
		}
		
		protected function get assetProxy() : AssetProxy {
			return facade.retrieveProxy(AssetProxy .NAME) as AssetProxy;
		}
	}
}
